package com.gr.experimental.model.impl.distr;

import java.util.List;

import com.gr.experimental.model.impl.distr.operations.PerformActionException;

public class Block implements Action {

	List<? extends Action> block;

	/**
	 * @param block list of actions to perform
	 */
	public Block(List<? extends Action> block) {
		this.block = block;
	}

	@Override
	public void perform(Context context) throws PerformActionException {
		// we should create subcontext here
		// as long as no variables may be declared
		// using the same context is safe
		
		for (Action action : block) {
			action.perform(context);
			if (context.isReturnCalled()) {
				return;
			}
		}
	}

}
